<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面导航</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #container {
            width: 100%;
            height: 100vh;
        }
    </style>
</head>

<body>
    <div id="container"></div>
    <script type="text/javascript"> // 本html页面里所使用的地图为高德地图
        window._AMapSecurityConfig = {
            securityJsCode: '3550f3a5226ce0cde9ae729164e98f27', // code和src分别填写我的应用里对应的key密钥和key
        }
    </script>
    <script type="text/javascript"
        src="https://webapi.amap.com/maps?v=1.4.15&key=c6dd63932be6086d7044f8340b18cace"></script>
    <script>
        var map = new AMap.Map("container", { // 调用高德地图的api
            zoom: 15, // 缩放级别
            center: [116.397428, 39.90923], // 位置中心点坐标
        })
        function beginDriving(start, end) { // 这个自定义的方法需要被调用
            AMap.plugin("AMap.Driving", function () { // 调用高德地图的api
                var driving = new AMap.Driving({
                    // 驾车路线规划策略，AMap.DrivingPolicy.LEAST_TIME是最快捷模式
                    policy: AMap.DrivingPolicy.LEAST_TIME,
                    map,
                })
                var points = [{ keyword: start }, { keyword: end }]
                driving.search(points, function (status, result) {
                    // 未出错时，result即是对应的路线规划方案
                })
            })
        }
        // beginDriving("北京火车站", "广州火车站") // 调用方法，测试导航是否ok
    </script>

</body>

</html>